//
//  FriendCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/8/13.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "FriendCell.h"

@interface FriendCell()

/**
 iconImg
 */
@property (nonatomic , strong) UIImageView *iconImgView;

/**
 messageNumLab
 */
@property (nonatomic , strong) UILabel *messageNumLab;

/**
 titleLab
 */
@property (nonatomic , strong) UILabel *titleLab;

/**
 timeLab
 */
@property (nonatomic , strong) UILabel *timeLab;

/**
 detailLab
 */
@property (nonatomic , strong) UILabel *detailLab;

@end


@implementation FriendCell

#pragma mark - lifecycle methods

- (void)setupUI
{
    // 添加子控件
    [self.contentView addSubview:self.iconImgView];
    [self.iconImgView addSubview:self.messageNumLab];
    [self.contentView addSubview:self.titleLab];
    [self.contentView addSubview:self.timeLab];
    [self.contentView addSubview:self.detailLab];

}

- (void)setupLayout
{
    // 布局子控件
    [self.iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(20);
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(50, 50));
    }];
    [self.messageNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.iconImgView.mas_left).offset(39);
        make.bottom.mas_equalTo(self.iconImgView.mas_bottom).offset(-35);
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.iconImgView.mas_right).offset(20);
        make.top.mas_equalTo(10);
        make.width.mas_equalTo(100);
    }];
    [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-20);
        make.top.mas_equalTo(12);
        make.left.mas_equalTo(self.titleLab.mas_right).offset(10);
    }];
    [self.detailLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.iconImgView.mas_right).offset(20);
        make.bottom.mas_equalTo(-14);
        make.right.mas_equalTo(-20);
    }];
}

#pragma mark - networking methods
#pragma mark - response methods
#pragma mark - public methods
#pragma mark - tableview.delegate methods
#pragma mark - tableview.datasource methods
#pragma mark - setter methods
#pragma mark - getter methods

- (UIImageView *)iconImgView {
    if (!_iconImgView) {
        _iconImgView = [[UIImageView alloc] init];
        //_iconImgView.backgroundColor = KRedColor;
        //[self addShadowAndCircleCorner:_iconImgView.layer corner:25];
        _iconImgView.image = [UIImage imageNamed:@"user_header"];
    }
    return _iconImgView;
}


- (UILabel *)messageNumLab {
    if (!_messageNumLab) {
        _messageNumLab = [[UILabel alloc] init];
        _messageNumLab.textColor = [UIColor whiteColor];
        _messageNumLab.font = [UIFont smallFont];
        _messageNumLab.backgroundColor = [UIColor colorWithHexString:@"#EE5B5B"];
        _messageNumLab.textAlignment = NSTextAlignmentCenter;
        _messageNumLab.layer.cornerRadius = 10;
        _messageNumLab.layer.masksToBounds = YES;
        _messageNumLab.hidden = YES;
    }
    return _messageNumLab;
}


- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.textColor = [UIColor textBlackColor];
        _titleLab.font = [UIFont largerFont];
        _titleLab.text = @"傅小小";
    }
    return _titleLab;
}


- (UILabel *)timeLab {
    if (!_timeLab) {
        _timeLab = [[UILabel alloc] init];
        _timeLab.textColor = [UIColor colorWithHexString:@"#B0B0B0"];
        _timeLab.font = [UIFont smallFont];
        _timeLab.textAlignment = NSTextAlignmentRight;
        _timeLab.text = @"刚刚";
    }
    return _timeLab;
}


- (UILabel *)detailLab {
    if (!_detailLab) {
        _detailLab = [[UILabel alloc] init];
        _detailLab.textColor = [UIColor colorWithHexString:@"#999999"];
        _detailLab.font = [UIFont middleFont];
        _detailLab.text = @"一日之计在于晨";
        
    }
    return _detailLab;
}


@end
